]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
ShellApp+ShellGlobal: unify app launch context code
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 19 Jan 2014 17:34:32 +0000 (18:34 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Sun, 19 Jan 2014 17:51:48 +0000 (18:51 +0100)
Extend shell_global_create_app_launch_context() with the required
parameters and use that for shell_app_launch() too.

https://bugzilla.gnome.org/show_bug.cgi?id=669603

js/misc/util.js
js/ui/components/autorunManager.js
js/ui/components/telepathyClient.js
js/ui/dateMenu.js
js/ui/lookingGlass.js
js/ui/messageTray.js
js/ui/remoteSearch.js
js/ui/runDialog.js
src/shell-app.c
src/shell-global.c
src/shell-global.h

index 9965c5a8f476ffdbc166a3821a98dc8c51304811..ba5de4a758cf3396f65c371a918838ef23af35f1 100644 (file)
@@ -89,7 +89,7 @@ function spawnApp(argv) {
         let app = Gio.AppInfo.create_from_commandline(argv.join(' '), null,
                                                       Gio.AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION);
 
-        let context = global.create_app_launch_context();
+        let context = global.create_app_launch_context(0, -1);
         app.launch([], context);
     } catch(err) {
         _handleSpawnError(argv[0], err);
index c58fa2e0d0c9cdcb1e63c777714e516e89957985..66077cbf3ebcf1b3296e322b562005624bc7f5c9 100644 (file)
@@ -64,7 +64,7 @@ function startAppForMount(app, mount) {
 
     try {
         retval = app.launch(files, 
-                            global.create_app_launch_context())
+                            global.create_app_launch_context(0, -1))
     } catch (e) {
         log('Unable to launch the application ' + app.get_name()
             + ': ' + e.toString());
index 56fc2d0fd50bf957a42f97727a4b9bf64d847418..e69c2a18e77357bf310cdac4dc78b3ac6b1df93b 100644 (file)
@@ -1339,7 +1339,7 @@ const AccountNotification = new Lang.Class({
             let cmd = 'empathy-accounts --select-account=' +
                 account.get_path_suffix();
             let app_info = Gio.app_info_create_from_commandline(cmd, null, 0);
-            app_info.launch([], global.create_app_launch_context());
+            app_info.launch([], global.create_app_launch_context(0, -1));
         }));
 
         this._enabledId = account.connect('notify::enabled',
index d851ed2bd1619714aaaf7bd648a64b0816eeefb4..ab7f26db85f2792664a49d890b11d37ef0564bb4 100644 (file)
@@ -211,7 +211,7 @@ const DateMenuButton = new Lang.Class({
         let app = this._getCalendarApp();
         if (app.get_id() == 'evolution.desktop')
             app = Gio.DesktopAppInfo.new('evolution-calendar.desktop');
-        app.launch([], global.create_app_launch_context());
+        app.launch([], global.create_app_launch_context(0, -1));
     },
 
     _onOpenClocksActivate: function() {
index a126d81af69f95d646da87f7de0a9e7465fb4e97..5c54d931bd67cbd248cf72fd38b8c62cf73b1dd3 100644 (file)
@@ -670,13 +670,13 @@ const Extensions = new Lang.Class({
     _onViewSource: function (actor) {
         let extension = actor._extension;
         let uri = extension.dir.get_uri();
-        Gio.app_info_launch_default_for_uri(uri, global.create_app_launch_context());
+        Gio.app_info_launch_default_for_uri(uri, global.create_app_launch_context(0, -1));
         this._lookingGlass.close();
     },
 
     _onWebPage: function (actor) {
         let extension = actor._extension;
-        Gio.app_info_launch_default_for_uri(extension.metadata.url, global.create_app_launch_context());
+        Gio.app_info_launch_default_for_uri(extension.metadata.url, global.create_app_launch_context(0, -1));
         this._lookingGlass.close();
     },
 
index f3806b7e674ac52ae0f3a3aabfbaf8429282bc98..53e838eb4ad2b79be110f4671147070eb7659357 100644 (file)
@@ -203,7 +203,7 @@ const URLHighlighter = new Lang.Class({
                 if (url.indexOf(':') == -1)
                     url = 'http://' + url;
 
-                Gio.app_info_launch_default_for_uri(url, global.create_app_launch_context());
+                Gio.app_info_launch_default_for_uri(url, global.create_app_launch_context(0, -1));
                 return Clutter.EVENT_STOP;
             }
             return Clutter.EVENT_PROPAGATE;
index 05a6ae927636c82b1c0ce7bf3c6b61a532348566..26017018aafc2f3c2e9069721cc773057e6b3f8c 100644 (file)
@@ -283,7 +283,7 @@ const RemoteSearchProvider = new Lang.Class({
         // the provider is not compatible with the new version of the interface, launch
         // the app itself but warn so we can catch the error in logs
         log('Search provider ' + this.appInfo.get_id() + ' does not implement LaunchSearch');
-        this.appInfo.launch([], global.create_app_launch_context());
+        this.appInfo.launch([], global.create_app_launch_context(0, -1));
     }
 });
 
index 7d9925375fc93ad95fb9a9abf5a346f07ff29f99..10cae4c36881cd0f514a5180b2093b52695b8880 100644 (file)
@@ -233,7 +233,7 @@ const RunDialog = new Lang.Class({
                     let file = Gio.file_new_for_path(path);
                     try {
                         Gio.app_info_launch_default_for_uri(file.get_uri(),
-                                                            global.create_app_launch_context());
+                                                            global.create_app_launch_context(0, -1));
                     } catch (e) {
                         // The exception from gjs contains an error string like:
                         //     Error invoking Gio.app_info_launch_default_for_uri: No application
index 283bd53e46ee8df431d1c8140859d2cb4fe36eaa..27f56af0692c0a8962af0da82f8e37134161c3b3 100644 (file)
@@ -1185,32 +1185,6 @@ app_child_setup (gpointer user_data)
 }
 #endif
 
-static GAppLaunchContext *
-make_launch_context (guint timestamp,
-                     int   workspace)
-{
-  GdkAppLaunchContext *context;
-  ShellGlobal *global;
-  MetaScreen *screen;
-  GdkDisplay *gdisplay;
-
-  global = shell_global_get ();
-  screen = shell_global_get_screen (global);
-  gdisplay = gdk_screen_get_display (shell_global_get_gdk_screen (global));
-
-  if (timestamp == 0)
-    timestamp = shell_global_get_current_time (global);
-
-  if (workspace < 0)
-    workspace = meta_screen_get_active_workspace_index (screen);
-
-  context = gdk_display_get_app_launch_context (gdisplay);
-  gdk_app_launch_context_set_timestamp (context, timestamp);
-  gdk_app_launch_context_set_desktop (context, workspace);
-
-  return G_APP_LAUNCH_CONTEXT (context);
-}
-
 /**
  * shell_app_launch:
  * @timestamp: Event timestamp, or 0 for current event timestamp
@@ -1223,6 +1197,7 @@ shell_app_launch (ShellApp     *app,
                   int           workspace,
                   GError      **error)
 {
+  ShellGlobal *global;
   GAppLaunchContext *context;
   gboolean ret;
 
@@ -1233,7 +1208,8 @@ shell_app_launch (ShellApp     *app,
       return TRUE;
     }
 
-  context = make_launch_context (timestamp, workspace),
+  global = shell_global_get ();
+  context = shell_global_create_app_launch_context (global, timestamp, workspace);
 
   ret = g_desktop_app_info_launch_uris_as_manager (app->info, NULL,
                                                    context,
@@ -1264,9 +1240,11 @@ shell_app_launch_action (ShellApp        *app,
                          guint            timestamp,
                          int              workspace)
 {
+  ShellGlobal *global;
   GAppLaunchContext *context;
 
-  context = make_launch_context (timestamp, workspace);
+  global = shell_global_get ();
+  context = shell_global_create_app_launch_context (global, timestamp, workspace);
 
   g_desktop_app_info_launch_action (G_DESKTOP_APP_INFO (app->info),
                                     action_name, context);
index 849278d8bfcb0fa3d8bc504a626f5e2d7e2dd66a..f961dadae8b9e405561f3063d4c17df4f6e1f9ee 100644 (file)
@@ -1326,6 +1326,8 @@ shell_global_get_current_time (ShellGlobal *global)
 /**
  * shell_global_create_app_launch_context:
  * @global: A #ShellGlobal
+ * @timestamp: the timestamp for the launch (or 0 for current time)
+ * @workspace: a workspace index, or -1 to indicate the current one
  *
  * Create a #GAppLaunchContext set up with the correct timestamp, and
  * targeted to activate on the current workspace.
@@ -1333,16 +1335,21 @@ shell_global_get_current_time (ShellGlobal *global)
  * Return value: (transfer full): A new #GAppLaunchContext
  */
 GAppLaunchContext *
-shell_global_create_app_launch_context (ShellGlobal *global)
+shell_global_create_app_launch_context (ShellGlobal *global,
+                                        int          timestamp,
+                                        int          workspace)
 {
   GdkAppLaunchContext *context;
 
   context = gdk_display_get_app_launch_context (global->gdk_display);
-  gdk_app_launch_context_set_timestamp (context, shell_global_get_current_time (global));
 
-  // Make sure that the app is opened on the current workspace even if
-  // the user switches before it starts
-  gdk_app_launch_context_set_desktop (context, meta_screen_get_active_workspace_index (global->meta_screen));
+  if (timestamp == 0)
+    timestamp = shell_global_get_current_time (global);
+  gdk_app_launch_context_set_timestamp (context, timestamp);
+
+  if (workspace < 0)
+    workspace = meta_screen_get_active_workspace_index (global->meta_screen);
+  gdk_app_launch_context_set_desktop (context, workspace);
 
   return (GAppLaunchContext *)context;
 }
index ec4a089635ff501ec67c6c480f1c0d12c6185997..71bdf7d8513617983d03d670221b9a67b3606a9f 100644 (file)
@@ -85,7 +85,9 @@ void shell_global_run_at_leisure (ShellGlobal          *global,
 void     shell_global_sync_pointer              (ShellGlobal  *global);
 
 GAppLaunchContext *
-         shell_global_create_app_launch_context (ShellGlobal  *global);
+         shell_global_create_app_launch_context (ShellGlobal  *global,
+                                                 int           timestamp,
+                                                 int           workspace);
 
 void     shell_global_play_theme_sound          (ShellGlobal *global,
                                                  guint        id,